package com.company.biz.user.action;

import com.company.biz.user.service.SendMessageService;
import com.company.common.exception.BizException;
import com.company.user.req.SendEmailReq;
import com.company.user.vo.GeneralResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(description = "发送消息管理")
@RestController
@RequestMapping("/sendMessage")
public class SendMessageController extends BaseController {
@Resource
private SendMessageService sendEmailService;

    @ApiOperation(value = "发送邮箱接口")
    @RequestMapping(value = "/sendEmail", method = RequestMethod.POST)
    public GeneralResult<String> sendEmail(@RequestBody SendEmailReq req) {
        if(StringUtils.isEmpty(req.getEmail())){
            throw new BizException("","请输入邮箱");
        }
        return sendEmailService.sendEmail(req.getEmail()) ? GeneralResult.genSuccessResult("发送成功"):GeneralResult.genErrorResult("发送失败");
    }

}
